import { RouteRecordRaw } from 'vue-router'
import LayoutTabbar from '@/layout/Tabbar.vue'

const router: Array<RouteRecordRaw> = [
  {
    path: '/',
    component: LayoutTabbar,
    children: [
      {
        path: 'home',
        name: 'Home',
        component: () =>
          import(
            /* webpackChunkName: "home" */ '@/views/home/Index.vue'
          ),
      },
      {
        path: 'person',
        name: 'Person',
        component: () =>
          import(
            /* webpackChunkName: "home" */ '@/views/person/Index.vue'
          ),
        meta: {
          isKeepAlive: false,
        },
        // 路由独享守卫
        beforeEnter: (to, from) => {
          to.meta.isKeepAlive =  to.name==='Person' && from.name=='PersonDetail' ? true : false
          return true
        },
      },
      {
        path: 'main',
        name: 'Main',
        component: () =>
          import(
            /* webpackChunkName: "home" */ '@/views/main/Index.vue'
          ),
        meta: {
          isKeepAlive: true,
        },
      }
    ]
  },
]
export default router
